﻿using Application.Purchase_dService;
using Domain.Entity.ord;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace WMSManage.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    [Authorize]//需要鉴权
    public class Purchase_dController : ControllerBase
    {
        private readonly IPurchase_dService purchase_DService;

        public Purchase_dController(IPurchase_dService purchase_DService)
        {
            this.purchase_DService = purchase_DService;
        }


        /// <summary>
        /// 新增进货明细单
        /// </summary>
        /// <param name="addPurchase_DDto"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<int> AddPurchase_d(AddPurchase_dDto addPurchase_DDto)
        {
            return await purchase_DService.AddPurchase_d(addPurchase_DDto);
        }



        /// <summary>
        /// 根据进货单id查询明细
        /// </summary>
        /// <param name="purid"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<List<Purchase_d>> GetPurchase_Ds(int purid)
        {
            return await purchase_DService.GetPurchase_Ds(purid);
        }



        /// <summary>
        /// 删除进货单明细
        /// </summary>
        /// <param name="purid"></param>
        /// <returns></returns>
        [HttpDelete]
        public async Task<int> DeletePurchase_d(int purid)
        {
            return await purchase_DService.DeletePurchase_d(purid);
        }


        [HttpPut]
        public async Task<int> UpdateRNum(int purtid, int returnnum, int newnum)
        {
            return await purchase_DService.UpdateRNum(purtid, returnnum, newnum);
        }
    }
}
